﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Churchtoolkit.Web.Shell.Presenters;
using Churchtoolkit.Utils.ErrorProvider;
using System.Web.Security;
using System.Collections;
using Churchtoolkit.DataAccess.Entities;
using Churchtoolkit.Web.Shell.Views;
using Churchtoolkit.DataAccess;

namespace Churchtoolkit.Web
{
    public partial class ChurchInformationView : Page<ChurchInformationPresenter>, IChurchInformationView
    {
        #region [ Events ]
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FilldlstCommittieslist();
            }
        }
        #endregion

        #region [ helpers ]
        private void FilldlstCommittieslist()
        {
            this.dlistcommities.DataSource = this.Presenter.CommittiesList();
            this.dlistcommities.DataBind();
        }
        #endregion

        public MemberCommitties CurrentComitty
        {
            get { return new MemberCommitties(); }
        }
        
        public Members CurrentMember
        {
            get { return new Members(); }
        }
        
        protected void Save(object sender, EventArgs e)
        {
            if (txtConfessionfather.Text != null)
            {
                this.Presenter.AddNewFather(txtConfessionfather.Text);
            }

            if (rdbWeekly.Checked == true)
            {
                CurrentComitty.OccurrenceType = (byte)Occurrencetype.Weekly;

                CurrentComitty.OccurreEveryWeeks = Convert.ToInt32(txtoccuerweekly.Text);

                //CurrentComitty.DayOfWeek = Convert.ToByte(ddlDayofweek.SelectedItem.Value);

                //CurrentComitty.TimeOfWeek =  Convert.ToByte(ddltimeofweek.SelectedItem);

                rdbMonthly.Enabled = false;
            }

            if (rdbMonthly.Checked == true)
            {
                CurrentComitty.OccurrenceType = (byte)Occurrencetype.Monthly;

                CurrentComitty.DayOfMonth = Convert.ToByte(txtDayofmonth.Text);

                CurrentComitty.OccurreEveryMonths = Convert.ToByte(txtOccuorEeveryMonth.Text);

            }

            if (chkserve.Checked == true)
            {
                CurrentComitty.ServantType = Convert.ToString( ddlserve.SelectedItem);
            }
        }

        protected void Remove(object sender, EventArgs e)
        {

        }

   
    }
}
